		
	//method to randomy generate the map
	function generateWorld() {
		
		// Create the wall along the x-axis which will form the boundaries
		for(var i = 0; i < 50; i++) {
			Crafty.e("2D, DOM, wall_top, wall, Collision")
				.attr({x: i * 16, y: 0, z: 2}).collision();
			Crafty.e("2D, DOM, wall_bottom, wall,Collision")
				.attr({x: i * 16, y: 624, z: 2}).collision();
		}
		
		// Create the wall along the y-axis
		for(var i = 1; i < 39; i++) {
			Crafty.e("2D, DOM, wall_left, wall, Collision")
				.attr({x: 0, y: i * 16, z: 2}).collision();
			Crafty.e("2D, DOM, wall_right, wall, Collision")
				.attr({x: 784, y: i * 16, z: 2}).collision();
		}
		
		// Create the horizontal walls
		for(var i = 1; i < 17; i++) {
			Crafty.e("2D, DOM, wall, wall, Collision")
				.attr({x: i * 16, y: 200, z: 2}).collision();
			Crafty.e("2D, DOM, wall, wall, Collision")
				.attr({x: i * 16, y: 370, z: 2}).collision();
		}
		
		for(var i = 27; i < 50; i++) {
			Crafty.e("2D, DOM, wall, wall, Collision")
				.attr({x: i * 16, y: 290, z: 2}).collision();
			Crafty.e("2D, DOM, wall, wall, Collision")
				.attr({x: i * 16, y: 448, z: 2}).collision();
		}
		
		// Create the vertical walls
		for(var i = 1; i < 5; i++) {
			Crafty.e("2D, DOM, wall, wall, Collision")
				.attr({x: 272, y: i * 16, z: 2}).collision();
		}
		
		for(var i = 8; i < 17; i++) {
			Crafty.e("2D, DOM, wall, wall, Collision")
				.attr({x: 272, y: i * 16, z: 2}).collision();
		}
		
		for(var i = 20; i < 30; i++) {
			Crafty.e("2D, DOM, wall, wall, Collision")
				.attr({x: 272, y: i * 16, z: 2}).collision();
		}
		
		for(var i = 33; i < 39; i++) {
			Crafty.e("2D, DOM, wall, wall, Collision")
				.attr({x: 272, y: i * 16, z: 2}).collision();
		}
		
		
		
		for(var i = 1; i < 7; i++) {
			Crafty.e("2D, DOM, wall, wall, Collision")
				.attr({x: 416, y: i * 16, z: 2}).collision();
		}
		
		for(var i = 10; i < 23; i++) {
			Crafty.e("2D, DOM, wall, wall, Collision")
				.attr({x: 416, y: i * 16, z: 2}).collision();
		}
		
		for(var i = 26; i < 32; i++) {
			Crafty.e("2D, DOM, wall, wall, Collision")
				.attr({x: 416, y: i * 16, z: 2}).collision();
		}
		
		for(var i = 35; i < 39; i++) {
			Crafty.e("2D, DOM, wall, wall, Collision")
				.attr({x: 416, y: i * 16, z: 2}).collision();
		}
		
		createSecurities();
		
		createItems();
	}

	
function createSecurities() {

        var security1 = Crafty.e("2D, Canvas, AI, Slide, security, Collision")
                              .attr({x:64, y:64}).collision().onHit("wall",function(obj) {
          this.cancelSlide();
        });
}

function createItems() {

        var item1 = Crafty.e("2D, Canvas, Item, flower")
                              .attr({x:32, y:32});
    	item1.setItemValue(50);
}